package es.uned.ii.si3.web.actions;



import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import es.uned.ii.si3.business.GestionSolicitudes;
import es.uned.ii.si3.exceptions.ObjectNotFoundException;
import es.uned.ii.si3.model.Solicitud;
import es.uned.ii.si3.util.UserAgentDetector;
import es.uned.ii.si3.web.actions.generic.LoginRequiredAction;


public class ListarSolicitudesPendientesAction extends LoginRequiredAction {


    public ActionForward executeWithAccess(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
    	
    	UserAgentDetector uaDetector = new UserAgentDetector(request);
    	
		GestionSolicitudes gestionSolicitudes = new GestionSolicitudes();		
		
		/* obtenemos todas las solicitudes pendientes de asignar a un profesor */

		List<Solicitud> listaSolicitudes=gestionSolicitudes.getSolicitudesPendientes();
		if (listaSolicitudes == null) {
			return mapping.findForward(uaDetector.composeForward("nohaySolicitudesPendientes"));
		}
		request.setAttribute("listaSolicitudes", listaSolicitudes);
		return mapping.findForward(uaDetector.composeForward("continue"));

			
    }
}
